package com.igeek.d0606;

import java.io.*;
import java.util.HashMap;

/**
 * @Author: zhiyu
 * @Date:19:05
 * @DESC:
 */
public class Test3 {
    public static void main(String[] args) {
        sortEssay();
    }
    public static void sortEssay(){
        HashMap<Integer, String> map = new HashMap<>();
        try (
                FileReader fileReader = new FileReader("D:\\copyTest\\SortBefore.txt");
                BufferedReader bd = new BufferedReader(fileReader);
                FileWriter fileWriter = new FileWriter("D:\\copyTest\\SortAfter.txt");
                BufferedWriter bw = new BufferedWriter(fileWriter);
        ){
            String s = "";
            while ((s=bd.readLine())!=null){
                if (s.startsWith("一")){
                    map.put(1,s);
                }
                if (s.startsWith("二")){
                    map.put(2,s);
                }
                if (s.startsWith("三")){
                    map.put(3,s);
                }
                if (s.startsWith("四")){
                    map.put(4,s);
                }
                if (s.startsWith("五")){
                    map.put(5,s);
                }
                if (s.startsWith("六")){
                    map.put(6,s);
                }
                if (s.startsWith("七")){
                    map.put(7,s);
                }
                if (s.startsWith("八")){
                    map.put(8,s);
                }
                if (s.startsWith("九")){
                    map.put(9,s);
                }
            }
            for (int i: map.keySet()) {
                bw.write(map.get(i));
                bw.newLine();
                bw.flush();
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }

    }
}
